package services.core;

import models.core.search.SearchFacetResultDto;
import models.core.search.SearchResultDto;

import org.h2.util.StringUtils;

import play.libs.F.Promise;
import services.ServiceException;

public class SearchService extends CoreService {
	
	public static Promise<SearchFacetResultDto> searchByFacet(String type, String... facets) throws ServiceException {
		return get( SearchFacetResultDto.class, "/search/find/type/" + type+ "/facets/", StringUtils.arrayCombine(facets, '/'));
	}
	
	public static Promise<SearchResultDto> search(String type, String text) throws ServiceException {
		return get( SearchResultDto.class, "/search/find/type/" + type+ "/", text );
	}
	
	public static Promise<SearchFacetResultDto> searchByFacet(String type, String text, String... facets) throws ServiceException {
		return get( SearchFacetResultDto.class, "/search/find/type/" + type+ "/" + text + "/facets/", StringUtils.arrayCombine(facets, '/') );
	}
}
